'use.strick'
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader')//vue-loader 打包vue文件加载器
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin =require('copy-webpack-plugin')
//公用配置
module.exports = {
  //入口文件
  entry: './src/main.js',
  //输出文件
  output: {
    path: path.resolve(__dirname, 'dist'),//输出文件名
    filename: 'bundle.[hash:8].js'
  },
  module:{
    rules: [
      {
        test: /\.css$/i,
          use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.less$/i,
          use: ['style-loader', 'css-loader','less-loader'],
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',//vue-template-compiler必须作为对等依赖项安装
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
        }
      },
    ],
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      // 根据模板插入css/js等生成最终HTML
      filename: 'index.html', // 生成的html存放路径，相对于 output.path
      favicon: './public/favicon.png', // 自动把根目录下的favicon.png图片加入html
      template: './public/index.html', // html模板路径
      inject: true, // 是否将js放在body的末尾
    }),
  new CopyWebpackPlugin({patterns:['./src/assets/**','public']})
  ],
  
};